import website from '@/config/website';
const validatePass = (rule, value, callback) => {
  if (value === '') {
    callback(new Error('请输入密码'));
  } else {
    callback();
  }
};
const validatePass2 = (rule, value, callback) => {
  if (value === '') {
    callback(new Error('请再次输入密码'));
  } else if (value !== this.form.password) {
    callback(new Error('两次输入密码不一致!'));
  } else {
    callback();
  }
};
export const userOption={
  align:'center',
  height: 'auto',
  calcHeight: 90,
  tip: false,
  searchShow: true,
  searchMenuSpan: 6,
  border: true,
  index: true,
  selection: true,
  columnBtn:false,
  dialogClickModal: false,
  dialogWidth:1000,
  dialogMenuPosition:'center',
  dialogCustomClass:'fixedtable2',
  addBtn:false,
  editBtn:false,
  viewBtn:false,
  delBtn:false,
  menuWidth:150,
  // maxHeight:document.documentElement.clientHeight -364,//有search
  column: [
    {
      label: "登录账号",
      prop: "account",
      search: true,
      display: false
    },
    {
      label: "所属租户",
      prop: "tenantName",
      slot: true,
      display: false
    },
    {
      label: "用户姓名",
      prop: "realName",
      search: true,
      display: false
    },
    {
      label: "所属角色",
      prop: "roleName",
      slot: true,
      display: false
    },
    {
      label: "所属部门",
      prop: "deptName",
      slot: true,
      display: false
    },
  ],
  group: [
    {
      label: '基础信息',
      prop: 'baseInfo',
      icon: 'el-icon-user-solid',
      column: [
        {
          label: "登录账号",
          prop: "account",
          search: true,
          rules: [{
            required: true,
            message: "请输入登录账号",
            trigger: "blur"
          }],
          span: website.tenantMode ? 12 : 24,
        },
        {
          label: "所属租户",
          prop: "tenantId",
          type: "tree",
          dicUrl: "/api/uic--system/tenant/select",
          props: {
            label: "tenantName",
            value: "tenantId"
          },
          hide: !website.tenantMode,
          addDisplay: website.tenantMode,
          editDisplay: website.tenantMode,
          viewDisplay: website.tenantMode,
          search: website.tenantMode,
          rules: [{
            required: true,
            message: "请输入所属租户",
            trigger: "click"
          }]
        },
        {
          label: '密码',
          prop: 'password',
          hide: true,
          editDisplay: false,
          viewDisplay: false,
          rules: [{required: true, validator: validatePass, trigger: 'blur'}]
        },
        {
          label: '确认密码',
          prop: 'password2',
          hide: true,
          editDisplay: false,
          viewDisplay: false,
          rules: [{required: true, validator: validatePass2, trigger: 'blur'}]
        },
      ]
    },
    {
      label: '详细信息',
      prop: 'detailInfo',
      icon: 'el-icon-s-order',
      column: [
        {
          label: "用户昵称",
          prop: "name",
          hide: true,
          rules: [{
            required: true,
            message: "请输入用户昵称",
            trigger: "blur"
          }]
        },
        {
          label: "用户姓名",
          prop: "realName",
          search: true,
          rules: [{
            required: true,
            message: "请输入用户姓名",
            trigger: "blur"
          }, {
            min: 2,
            max: 5,
            message: '姓名长度在2到5个字符'
          }]
        },
        {
          label: "手机号码",
          prop: "phone",
          overHidden: true
        },
        {
          label: "电子邮箱",
          prop: "email",
          hide: true,
          overHidden: true
        },
        {
          label: "用户性别",
          prop: "sex",
          type: "select",
          dicData: [
            {
              label: "男",
              value: 1
            },
            {
              label: "女",
              value: 2
            },
            {
              label: "未知",
              value: 3
            }
          ],
          hide: true
        },
        {
          label: "用户生日",
          type: "date",
          prop: "birthday",
          format: "yyyy-MM-dd hh:mm:ss",
          valueFormat: "yyyy-MM-dd hh:mm:ss",
          hide: true
        },
        {
          label: "账号状态",
          prop: "statusName",
          hide: true,
          display: false
        }
      ]
    },
    {
      label: '职责信息',
      prop: 'dutyInfo',
      icon: 'el-icon-s-custom',
      column: [
        {
          label: "用户编号",
          prop: "code",
        },
        {
          label: "所属角色",
          prop: "roleId",
          multiple: true,
          type: "tree",
          dicData: [],
          props: {
            label: "title"
          },
          checkStrictly: true,
          slot: true,
          rules: [{
            required: true,
            message: "请选择所属角色",
            trigger: "click"
          }]
        },
        {
          label: "所属部门",
          prop: "deptId",
          type: "tree",
          multiple: true,
          dicData: [],
          props: {
            label: "title"
          },
          checkStrictly: true,
          slot: true,
          rules: [{
            required: true,
            message: "请选择所属部门",
            trigger: "click"
          }]
        },
        {
          label: "所属岗位",
          prop: "postId",
          type: "tree",
          multiple: true,
          dicData: [],
          props: {
            label: "postName",
            value: "id"
          },
          rules: [{
            required: true,
            message: "请选择所属岗位",
            trigger: "click"
          }],
        },
      ]
    },
  ]
}
